package com.company;

import java.util.ArrayList;
import java.util.List;

/**
 * @date : 2023-03-09 上午9:54
 * 达不到数据最大上界，出现OOM异常
 * Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
 * 	at java.util.Arrays.copyOf(Arrays.java:3210)
 * 	at java.util.Arrays.copyOf(Arrays.java:3181)
 * 	at java.util.ArrayList.grow(ArrayList.java:265)
 * 	at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:239)
 * 	at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:231)
 * 	at java.util.ArrayList.add(ArrayList.java:462)
 * 	at com.company.P042_ArrayListMaxSize.main(P042_ArrayListMaxSize.java:16)
 *
 */

public class P042_ArrayListMaxSize {

    public static void main(String[] args) {
        List<Long> list = new ArrayList<>();
        for (long i = 0; i < Long.MAX_VALUE; i++) {
            list.add(i);
        }
    }

}
